$(function () {
    var token = localStorage.getItem('token')
    renderSlider()

    function renderSlider() {
        $.ajax({
            type: "get",
            url: "http://192.168.23.30:3000/interests/" + token,
            success: function (res) {
                console.log(res);
                // console.log(res[0].img);
                var htmlstr = template('tpl-slider', res)
                console.log(htmlstr);
                $('.mui-slider-loop').html(htmlstr)
                //获得slider插件对象
                var gallery = mui('.mui-slider');
                gallery.slider({
                    interval: 2000 //自动轮播周期，若为0则不自动播放，默认为0；
                });
            }
        });
    }

    function detail_intro() {
        $.ajax({
            type: "get",
            url: "http://192.168.23.30:3000/interests/" + token,
            success: function (res) {
                // console.log(res);
                var htmlstr = template('tpl_detail_itro', res)
                $('.detail-itro').html(htmlstr)
                // console.log(res[0].on_sale);
                if (res.on_sale) {
                    $('.mui-btn-warning').css('background-color', '#ff6633').siblings('.mui-btn-danger').css('background-color', '#cccccc')
                } else {
                    $('.mui-btn-warning').css('background-color', '#cccccc').siblings('.mui-btn-danger').css('background-color', '#ff6633')
                }
                $('.nowprice').html('¥' + res.price_current)
                $('.oldprice').html('¥' + res.price_old)
                $('#maxPirce').html('¥' + res.price_old)
                $('#tuanPirce').html(res.price_current)
                var htmls1 = template('model1', res)
                $('.tg_box').html(htmls1)
            }
        });
    }
    detail_intro()

    $('.return').on('click', function () {
        location.href = 'index.html'
    })














})